home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / knowhow4 / prn_rec.h < prev    next >
C/C++ Source or Header  |  1994-10-10  |  2KB  |  80 lines

  1. #ifndef __PRINT_RECORD_H_
  2. #define __PRINT_RECORD_H_
  3.  
  4. #include "geom.h"
  5. #include <string.h>
  6.  
  7. #define ALLOCATION_STEP 20
  8.  
  9. /*  Each time we print record, we do the same group of operations.
  10.        The sequence of operations is written on some pseudo-language.
  11. */
  12.  
  13. // Type of additional information
  14. enum { TEXT_INFO, PCX_INFO, DATE_INFO, PAGE_INFO, REC_NO_INFO };
  15.  
  16. // Fields in record.
  17. struct FIELD_LAYOUT
  18.     {
  19.     rect coord;                // Clip area on record, cells
  20.     int fieldNumber;           // Number of field in table (first is 1)
  21.  
  22.     FIELD_LAYOUT(rect r, int f) { coord = r; fieldNumber = f; }
  23.     };
  24.  
  25. // Non-field information repeated with every record
  26. struct ADDINFO_LAYOUT
  27.     {
  28.     loc pos;                   // Left - top position on record, cells
  29.     int info_type;             // Text or PCX
  30.     char* str;                 // Text, file name and so on
  31.     int service[6];            // For PCX it is width, height, deformation,
  32.                    // for text - font,
  33.                    // size and color and so on.
  34.     ADDINFO_LAYOUT(loc p, int t, char* s = "",
  35.            int s0 = 0, int s1 = 0, int s2 = 0,
  36.            int s3 = 0, int s4 = 0)
  37.     { pos = p; info_type = t; str = strdup(s);
  38.       service[0] = s0; service[1] = s1;
  39.       service[2] = s2; service[3] = s3; service[4] = s4;
  40.       service[5] = TEXT_INFO; }
  41.     ~ADDINFO_LAYOUT() { delete str; }
  42.     };
  43.  
  44. // Two structures operates with fields and addinfo lists.
  45. struct FIELD_LIST
  46.     {
  47.     int total_fields;          // Allocated;
  48.     int used_fields;           // Number of fields
  49.  
  50.     FIELD_LAYOUT** field_list; // List of fields to be printed
  51.  
  52.     FIELD_LIST();
  53.     ~FIELD_LIST();
  54.  
  55.     void add(FIELD_LAYOUT* field, int number);
  56.     FIELD_LAYOUT* remove_field(int number);
  57.     };
  58.  
  59. struct ADD_LIST
  60.     {
  61.     int total_add;             // Allocated;
  62.     int used_add;              // Number of fields
  63.  
  64.     ADDINFO_LAYOUT** add_list; // Additional information for record
  65.  
  66.     ADD_LIST();
  67.     ~ADD_LIST();
  68.  
  69.     void add(ADDINFO_LAYOUT* add, int number);
  70.     ADDINFO_LAYOUT* remove_add(int number);
  71.     };
  72.  
  73. // Record is printed as the list of fields and non-field (additive) data
  74. struct RECORD_LAYOUT : public FIELD_LIST, public ADD_LIST
  75.     {
  76.     RECORD_LAYOUT();
  77.     };
  78.  
  79.  
  80. #endif __PRINT_RECORD_H_